#ifndef DOMAIN_H
#define DOMAIN_H

#if defined(Viewer3DAPI)
#  define Viewer3DAPI_EXPORT Q_DECL_EXPORT
#else
#  define Viewer3DAPI_EXPORT
#endif

#include <QMainWindow>
#include <QFileDialog>
#include <QMessageBox>
#include <QLabel>

#include "ModelFileLoader.h"
#include "ModelAlgoManager.h"
#include "ModelViewer.h"
#include "ModelDisplayer.h"

#include "ModelColorPalette.h"
#include "SnapShotSettingDialog.h"
#include "SlicingSettingsDialog.h"

#include "PreviewDirectionSelector.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class Domain;
}
QT_END_NAMESPACE

Q_DECLARE_METATYPE(QVector<QVector<QVector<QPointF>>>)

class Viewer3DAPI_EXPORT Domain : public QMainWindow
{
    Q_OBJECT

public:
    Domain(QWidget *parent = nullptr);
    ~Domain();

private:
    void initUI();
    void refreshUI();
    void initConnections();
    void initModelWidget();
    void updateCurrentFileLabel(const QString &stl_file_path);

private slots:
    void on_actionOpenFile_triggered();
    void on_actionSaveAs_triggered();
    void on_actionRadialGrayScaleConvertion_triggered();
    void on_actionGlobalGrayScaleConvertion_triggered();
    void on_actionGrayScaleConvertionCancel_triggered();
    void on_actionPureColorSetting_triggered();
    void on_actionCancelPureColor_triggered();
    void on_actionViewPortMatched_triggered();
    void on_actionViewPortFilled_triggered();
    void on_actionPreview_triggered();
    void on_actionModelScaling_triggered();
    void on_actionContoursExtraction_triggered();

signals:
    void sendAllContours(const QVector<QVector<QVector<QPointF>>>& all_contours, float stride, const QVector<float>& spaces);

private:
    std::shared_ptr<IModelFileLoader> m_sptr_modelLoader;
    std::shared_ptr<ModelAlgoManager> m_sptr_modelAlgoManager;
    std::shared_ptr<ViewCamera> m_sptr_viewCamera;
    std::shared_ptr<ModelDisplayer> m_sptr_modelDisplayer;
    std::shared_ptr<SnapShotSettingDialog> m_sptr_snapShotSetting;
    std::shared_ptr<ModelColorPalette> m_sptr_modelColorPalette;
    std::shared_ptr<PreviewDirectionSelector> m_sptr_previewDirectionSelector;
    std::shared_ptr<SlicingSettingsDialog> m_sptr_slicingSetting;

private:
    QLabel *fLabCurFile;
    Ui::Domain *ui;
};
#endif // DOMAIN_H
